本文整理了Java中org.openid4java.association.Association.sign()
方法的一些代码示例,展示了Association.sign()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Association.sign()
方法的具体详情如下:
包路径:org.openid4java.association.Association
类名称:Association
方法名:sign
暂无
代码示例来源:origin: org.openid4java/openid4java-nodeps
public boolean verifySignature(String text, String signature) throws AssociationException
{
if (DEBUG) _log.debug("Verifying signature: " + signature);
// The Java String.equals() method returns on the first difference in
// its inputs, which allows a timing attack to recover signature values.
// This verification method will take the same amount of time for any
// two inputs of equal length.
String textSig = sign(text);
if (textSig.length() == 0 || textSig.length() != signature.length()) {
return false;
}
int result = 0;
for (int i = 0; i < textSig.length(); i++) {
result |= textSig.charAt(i) ^ signature.charAt(i);
}
return result == 0;
}
}
代码示例来源:origin: com.cloudbees/openid4java-shaded
public boolean verifySignature(String text, String signature) throws AssociationException
{
if (DEBUG) _log.debug("Verifying signature: " + signature);
// The Java String.equals() method returns on the first difference in
// its inputs, which allows a timing attack to recover signature values.
// This verification method will take the same amount of time for any
// two inputs of equal length.
String textSig = sign(text);
if (textSig.length() == 0 || textSig.length() != signature.length()) {
return false;
}
int result = 0;
for (int i = 0; i < textSig.length(); i++) {
result |= textSig.charAt(i) ^ signature.charAt(i);
}
return result == 0;
}
}
代码示例来源:origin: org.openid4java/openid4java
public boolean verifySignature(String text, String signature) throws AssociationException
{
if (DEBUG) _log.debug("Verifying signature: " + signature);
// The Java String.equals() method returns on the first difference in
// its inputs, which allows a timing attack to recover signature values.
// This verification method will take the same amount of time for any
// two inputs of equal length.
String textSig = sign(text);
if (textSig.length() == 0 || textSig.length() != signature.length()) {
return false;
}
int result = 0;
for (int i = 0; i < textSig.length(); i++) {
result |= textSig.charAt(i) ^ signature.charAt(i);
}
return result == 0;
}
}
代码示例来源:origin: jbufu/openid4java
public String sign(String text) throws AssociationException
{
if (DEBUG) _log.debug("Computing signature for input data:\n" + text);
try
{
String signature = new String(Base64.encodeBase64(sign(text.getBytes("utf-8"))), "utf-8");
if (DEBUG)
_log.debug("Calculated signature: " + signature);
return signature;
}
catch (UnsupportedEncodingException e)
{
throw new AssociationException("Unsupported encoding for signed text.", e);
}
}
代码示例来源:origin: org.wso2.org.openid4java/openid4java-nodeps
public String sign(String text) throws AssociationException {
if (DEBUG) {
_log.debug("Computing signature for input data:\n" + text);
}
try {
String signature = new String(Base64.encodeBase64(sign(text.getBytes("utf-8"))), "utf-8");
if (DEBUG) {
_log.debug("Calculated signature: " + signature);
}
return signature;
} catch (UnsupportedEncodingException e) {
throw new AssociationException("Unsupported encoding for signed text.", e);
}
}
代码示例来源:origin: org.wso2.org.openid4java/openid4java-nodeps
public boolean verifySignature(String text, String signature) throws AssociationException {
if (DEBUG) {
_log.debug("Verifying signature: " + signature);
}
// The Java String.equals() method returns on the first difference in
// its inputs, which allows a timing attack to recover signature values.
// This verification method will take the same amount of time for any
// two inputs of equal length.
String textSig = sign(text);
if (textSig.length() == 0 || textSig.length() != signature.length()) {
return false;
}
int result = 0;
for (int i = 0; i < textSig.length(); i++) {
result |= textSig.charAt(i) ^ signature.charAt(i);
}
return result == 0;
}
}
代码示例来源:origin: org.openid4java/openid4java
public String sign(String text) throws AssociationException
{
if (DEBUG) _log.debug("Computing signature for input data:\n" + text);
try
{
String signature = new String(Base64.encodeBase64(sign(text.getBytes("utf-8"))), "utf-8");
if (DEBUG)
_log.debug("Calculated signature: " + signature);
return signature;
}
catch (UnsupportedEncodingException e)
{
throw new AssociationException("Unsupported encoding for signed text.", e);
}
}
代码示例来源:origin: jbufu/openid4java
public boolean verifySignature(String text, String signature) throws AssociationException
{
if (DEBUG) _log.debug("Verifying signature: " + signature);
// The Java String.equals() method returns on the first difference in
// its inputs, which allows a timing attack to recover signature values.
// This verification method will take the same amount of time for any
// two inputs of equal length.
String textSig = sign(text);
if (textSig.length() == 0 || textSig.length() != signature.length()) {
return false;
}
int result = 0;
for (int i = 0; i < textSig.length(); i++) {
result |= textSig.charAt(i) ^ signature.charAt(i);
}
return result == 0;
}
}
代码示例来源:origin: org.openid4java/openid4java-nodeps
public String sign(String text) throws AssociationException
{
if (DEBUG) _log.debug("Computing signature for input data:\n" + text);
try
{
String signature = new String(Base64.encodeBase64(sign(text.getBytes("utf-8"))), "utf-8");
if (DEBUG)
_log.debug("Calculated signature: " + signature);
return signature;
}
catch (UnsupportedEncodingException e)
{
throw new AssociationException("Unsupported encoding for signed text.", e);
}
}
代码示例来源:origin: com.cloudbees/openid4java-shaded
public String sign(String text) throws AssociationException
{
if (DEBUG) _log.debug("Computing signature for input data:\n" + text);
try
{
String signature = new String(Base64.encodeBase64(sign(text.getBytes("utf-8"))), "utf-8");
if (DEBUG)
_log.debug("Calculated signature: " + signature);
return signature;
}
catch (UnsupportedEncodingException e)
{
throw new AssociationException("Unsupported encoding for signed text.", e);
}
}
代码示例来源:origin: org.openid4java/openid4java-nodeps
/**
* Signs an AuthSuccess message, using the association identified by the
* handle specified within the message.
*
* @param authSuccess The Authentication Success message to be signed.
*
* @throws ServerException If the Association corresponding to the handle
* in the @authSuccess cannot be retrieved from
* the store.
* @throws AssociationException If the signature cannot be computed.
*
*/
public void sign(AuthSuccess authSuccess)
throws ServerException, AssociationException
{
String handle = authSuccess.getHandle();
// try shared associations first, then private
Association assoc = _sharedAssociations.load(handle);
if (assoc == null)
assoc = _privateAssociations.load(handle);
if (assoc == null) throw new ServerException(
"No association found for handle: " + handle);
authSuccess.setSignature(assoc.sign(authSuccess.getSignedText()));
}
代码示例来源:origin: com.cloudbees/openid4java-shaded
/**
* Signs an AuthSuccess message, using the association identified by the
* handle specified within the message.
*
* @param authSuccess The Authentication Success message to be signed.
*
* @throws ServerException If the Association corresponding to the handle
* in the @authSuccess cannot be retrieved from
* the store.
* @throws AssociationException If the signature cannot be computed.
*
*/
public void sign(AuthSuccess authSuccess)
throws ServerException, AssociationException
{
String handle = authSuccess.getHandle();
// try shared associations first, then private
Association assoc = _sharedAssociations.load(handle);
if (assoc == null)
assoc = _privateAssociations.load(handle);
if (assoc == null) throw new ServerException(
"No association found for handle: " + handle);
authSuccess.setSignature(assoc.sign(authSuccess.getSignedText()));
}
代码示例来源:origin: jbufu/openid4java
/**
* Signs an AuthSuccess message, using the association identified by the
* handle specified within the message.
*
* @param authSuccess The Authentication Success message to be signed.
*
* @throws ServerException If the Association corresponding to the handle
* in the @authSuccess cannot be retrieved from
* the store.
* @throws AssociationException If the signature cannot be computed.
*
*/
public void sign(AuthSuccess authSuccess)
throws ServerException, AssociationException
{
String handle = authSuccess.getHandle();
// try shared associations first, then private
Association assoc = _sharedAssociations.load(handle);
if (assoc == null)
assoc = _privateAssociations.load(handle);
if (assoc == null) throw new ServerException(
"No association found for handle: " + handle);
authSuccess.setSignature(assoc.sign(authSuccess.getSignedText()));
}
代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.openid/org.wso2.carbon.identity.provider
public void sign(AuthSuccess authSuccess)
throws ServerException, AssociationException {
String handle = authSuccess.getHandle();
Association assoc = null;
try {
// First try in thread local
assoc = getThreadLocalAssociation();
} finally {
// Clear thread local
clearThreadLocalAssociation();
}
// try shared associations, then private
if (assoc == null) {
assoc = getSharedAssociations().load(handle);
}
if (assoc == null) {
assoc = getPrivateAssociations().load(handle);
}
if (assoc == null) {
throw new ServerException("No association found for handle: " + handle);
}
authSuccess.setSignature(assoc.sign(authSuccess.getSignedText()));
}
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.provider
public void sign(AuthSuccess authSuccess)
throws ServerException, AssociationException {
String handle = authSuccess.getHandle();
Association assoc = null;
try {
// First try in thread local
assoc = getThreadLocalAssociation();
} finally {
// Clear thread local
clearThreadLocalAssociation();
}
// try shared associations, then private
if (assoc == null) {
assoc = getSharedAssociations().load(handle);
}
if (assoc == null) {
assoc = getPrivateAssociations().load(handle);
}
if (assoc == null) {
throw new ServerException("No association found for handle: " + handle);
}
authSuccess.setSignature(assoc.sign(authSuccess.getSignedText()));
}
代码示例来源:origin: com.cloudbees/openid4java-shaded
protected AuthSuccess(String opEndpoint, String claimedId, String delegate,
boolean compatibility,
String returnTo, String nonce,
String invalidateHandle, Association assoc,
boolean signNow)
throws AssociationException
{
if (! compatibility)
{
set("openid.ns", OPENID2_NS);
setOpEndpoint(opEndpoint);
setClaimed(claimedId);
setNonce(nonce);
}
set("openid.mode", MODE_IDRES);
setIdentity(delegate);
setReturnTo(returnTo);
if (invalidateHandle != null) setInvalidateHandle(invalidateHandle);
setHandle(assoc.getHandle());
buildSignedList();
setSignature(signNow ? assoc.sign(getSignedText()) : "");
}
代码示例来源:origin: org.wso2.org.openid4java/openid4java-nodeps
protected AuthSuccess(String opEndpoint, String claimedId, String delegate,
boolean compatibility,
String returnTo, String nonce,
String invalidateHandle, Association assoc,
boolean signNow)
throws AssociationException {
if (!compatibility) {
set("openid.ns", OPENID2_NS);
setOpEndpoint(opEndpoint);
setClaimed(claimedId);
setNonce(nonce);
}
set("openid.mode", MODE_IDRES);
setIdentity(delegate);
setReturnTo(returnTo);
if (invalidateHandle != null) {
setInvalidateHandle(invalidateHandle);
}
setHandle(assoc.getHandle());
buildSignedList();
setSignature(signNow ? assoc.sign(getSignedText()) : "");
}
代码示例来源:origin: org.openid4java/openid4java
protected AuthSuccess(String opEndpoint, String claimedId, String delegate,
boolean compatibility,
String returnTo, String nonce,
String invalidateHandle, Association assoc,
boolean signNow)
throws AssociationException
{
if (! compatibility)
{
set("openid.ns", OPENID2_NS);
setOpEndpoint(opEndpoint);
setClaimed(claimedId);
setNonce(nonce);
}
set("openid.mode", MODE_IDRES);
setIdentity(delegate);
setReturnTo(returnTo);
if (invalidateHandle != null) setInvalidateHandle(invalidateHandle);
setHandle(assoc.getHandle());
buildSignedList();
setSignature(signNow ? assoc.sign(getSignedText()) : "");
}
代码示例来源:origin: org.openid4java/openid4java-nodeps
protected AuthSuccess(String opEndpoint, String claimedId, String delegate,
boolean compatibility,
String returnTo, String nonce,
String invalidateHandle, Association assoc,
boolean signNow)
throws AssociationException
{
if (! compatibility)
{
set("openid.ns", OPENID2_NS);
setOpEndpoint(opEndpoint);
setClaimed(claimedId);
setNonce(nonce);
}
set("openid.mode", MODE_IDRES);
setIdentity(delegate);
setReturnTo(returnTo);
if (invalidateHandle != null) setInvalidateHandle(invalidateHandle);
setHandle(assoc.getHandle());
buildSignedList();
setSignature(signNow ? assoc.sign(getSignedText()) : "");
}
代码示例来源:origin: jbufu/openid4java
protected AuthSuccess(String opEndpoint, String claimedId, String delegate,
boolean compatibility,
String returnTo, String nonce,
String invalidateHandle, Association assoc,
boolean signNow)
throws AssociationException
{
if (! compatibility)
{
set("openid.ns", OPENID2_NS);
setOpEndpoint(opEndpoint);
setClaimed(claimedId);
setNonce(nonce);
}
set("openid.mode", MODE_IDRES);
setIdentity(delegate);
setReturnTo(returnTo);
if (invalidateHandle != null) setInvalidateHandle(invalidateHandle);
setHandle(assoc.getHandle());
buildSignedList();
setSignature(signNow ? assoc.sign(getSignedText()) : "");
}
内容来源于网络,如有侵权,请联系作者删除!