本文整理汇总了Java中org.xdi.oxauth.model.util.Util类的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Util类属于org.xdi.oxauth.model.util包,在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPropertyValue
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
public String getPropertyValue(String propertyName) {
if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_AUTHORIZE_URL, propertyName)) {
return openIdConfiguration.getAuthorizationEndpoint();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_TOKEN_URL, propertyName)) {
return openIdConfiguration.getTokenEndpoint();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_TOKEN_VALIDATION_URL, propertyName)) {
return openIdConfiguration.getValidateTokenEndpoint();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_USERINFO_URL, propertyName)) {
return openIdConfiguration.getUserInfoEndpoint();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_LOGOUT_URL, propertyName)) {
return openIdConfiguration.getEndSessionEndpoint();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_LOGOUT_REDIRECT_URL, propertyName)) {
return appConfiguration.getOpenIdPostLogoutRedirectUri();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_CLIENT_ID, propertyName)) {
return appConfiguration.getOpenIdClientId();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_CLIENT_PASSWORD, propertyName)) {
return appConfiguration.getOpenIdClientPassword();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_CLIENT_SCOPE, propertyName)) {
return Util.listAsString(appConfiguration.getOpenIdScopes());
}
return null;
}
示例2: TestModeScimClient
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
/**
* Constructs a TestModeScimClient object with the specified parameters and service contract
* @param serviceClass The service interface the underlying resteasy proxy client will adhere to. This proxy is used
* internally to execute all requests to the service
* @param serviceUrl The root URL of the SCIM service. Usually in the form {@code https://your.gluu-server.com/identity/restv1}
* @param OIDCMetadataUrl URL of authorization servers' metadata document. Usually in the form {@code https://your.gluu-server.com/.well-known/openid-configuration}
* @throws Exception If there was a problem contacting the authorization server to initialize this object
*/
public TestModeScimClient(Class<T> serviceClass, String serviceUrl, String OIDCMetadataUrl) throws Exception {
super(serviceUrl, serviceClass);
//Extract token, registration, and authz endpoints from metadata URL
JsonNode tree=mapper.readTree(new URL(OIDCMetadataUrl));
this.registrationEndpoint= tree.get("registration_endpoint").asText();
this.tokenEndpoint=tree.get("token_endpoint").asText();
//this.authzEndpoint=tree.get("authorization_endpoint").asText();
if (Util.allNotBlank(registrationEndpoint, tokenEndpoint /*, authzEndpoint*/)) {
triggerRegistrationIfNeeded();
updateTokens(GrantType.CLIENT_CREDENTIALS);
}
else
throw new Exception("Couldn't extract endpoints from OIDC metadata URL: " + OIDCMetadataUrl);
}
示例3: getPropertyValue
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
public String getPropertyValue(String propertyName) {
if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_AUTHORIZE_URL, propertyName)) {
return openIdConfiguration.getAuthorizationEndpoint();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_TOKEN_URL, propertyName)) {
return openIdConfiguration.getTokenEndpoint();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_USERINFO_URL, propertyName)) {
return openIdConfiguration.getUserInfoEndpoint();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_LOGOUT_URL, propertyName)) {
return openIdConfiguration.getEndSessionEndpoint();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_LOGOUT_REDIRECT_URL, propertyName)) {
return appConfiguration.getOpenIdPostLogoutRedirectUri();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_CLIENT_ID, propertyName)) {
return appConfiguration.getOpenIdClientId();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_CLIENT_PASSWORD, propertyName)) {
return appConfiguration.getOpenIdClientPassword();
} else if (StringHelper.equalsIgnoreCase(Configuration.OAUTH_PROPERTY_CLIENT_SCOPE, propertyName)) {
return Util.listAsString(appConfiguration.getOpenIdScopes());
}
return null;
}
示例4: request
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
public static Token request(final String tokenUrl, final String umaClientId, final String umaClientSecret, UmaScopeType scopeType,
ClientExecutor clientExecutor, String... scopeArray) throws Exception {
String scope = scopeType.getValue();
if (scopeArray != null && scopeArray.length > 0) {
for (String s : scopeArray) {
scope = scope + " " + s;
}
}
TokenClient tokenClient = new TokenClient(tokenUrl);
if (clientExecutor != null) {
tokenClient.setExecutor(clientExecutor);
}
TokenResponse response = tokenClient.execClientCredentialsGrant(scope, umaClientId, umaClientSecret);
if (response.getStatus() == 200) {
final String patToken = response.getAccessToken();
final Integer expiresIn = response.getExpiresIn();
if (Util.allNotBlank(patToken)) {
return new Token(null, null, patToken, scopeType.getValue(), expiresIn);
}
}
return null;
}
示例5: parametersAsString
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
public String parametersAsString(final Map<String, String> parameterMap) throws UnsupportedEncodingException {
final StringBuilder sb = new StringBuilder();
final Set<Entry<String, String>> set = parameterMap.entrySet();
for (Map.Entry<String, String> entry : set) {
final String value = (String) entry.getValue();
if (StringUtils.isNotBlank(value)) {
sb.append(entry.getKey()).append("=").append(URLEncoder.encode(value, Util.UTF8_STRING_ENCODING)).append("&");
}
}
String result = sb.toString();
if (result.endsWith("&")) {
result = result.substring(0, result.length() - 1);
}
return result;
}
示例6: getPermissionFromRPTByResourceId
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
public UmaPermission getPermissionFromRPTByResourceId(UmaRPT rpt, String resourceId) {
try {
if (Util.allNotBlank(resourceId)) {
for (UmaPermission permission : getRptPermissions(rpt)) {
if (resourceId.equals(permission.getResourceId())) {
return permission;
}
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return null;
}
示例7: restoreLogoutParametersFromSession
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
private boolean restoreLogoutParametersFromSession(SessionId sessionId) throws IllegalArgumentException, JsonParseException, JsonMappingException, IOException {
if (sessionId == null) {
return false;
}
this.sessionId = sessionId;
Map<String, String> sessionAttributes = sessionId.getSessionAttributes();
boolean restoreParameters = sessionAttributes.containsKey(EXTERNAL_LOGOUT);
if (!restoreParameters) {
return false;
}
String logoutParametersBase64 = sessionAttributes.get(EXTERNAL_LOGOUT_DATA);
String logoutParametersJson = new String(Base64Util.base64urldecode(logoutParametersBase64), Util.UTF8_STRING_ENCODING);
LogoutParameters logoutParameters = jsonService.jsonToObject(logoutParametersJson, LogoutParameters.class);
this.idTokenHint = logoutParameters.getIdTokenHint();
this.postLogoutRedirectUri = logoutParameters.getPostLogoutRedirectUri();
return true;
}
示例8: checkUiLocales
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
public void checkUiLocales() {
List<String> uiLocalesList = null;
if (StringUtils.isNotBlank(uiLocales)) {
uiLocalesList = Util.splittedStringAsList(uiLocales, " ");
List<Locale> supportedLocales = new ArrayList<Locale>();
for (Iterator<Locale> it = facesContext.getApplication().getSupportedLocales(); it.hasNext(); ) {
supportedLocales.add(it.next());
}
Locale matchingLocale = LocaleUtil.localeMatch(uiLocalesList, supportedLocales);
if (matchingLocale != null)
languageBean.setLocaleCode(matchingLocale.getLanguage());
} else {
Locale defaultLocale = facesContext.getApplication().getDefaultLocale();
if (defaultLocale != null) {
languageBean.setLocaleCode(defaultLocale.getLanguage());
}
}
}
示例9: getQueryString
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
public String getQueryString() {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : responseParameters.entrySet()) {
if (sb.length() > 0) {
sb.append('&');
}
try {
sb.append(URLEncoder.encode(entry.getKey(), Util.UTF8_STRING_ENCODING));
if (entry.getValue() != null) {
sb.append('=').append(URLEncoder.encode(entry.getValue(), Util.UTF8_STRING_ENCODING));
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return sb.toString();
}
示例10: PureJwt
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
public PureJwt(String p_encodedHeader, String p_encodedPayload, String p_encodedSignature) {
m_encodedHeader = p_encodedHeader;
m_encodedPayload = p_encodedPayload;
m_encodedSignature = p_encodedSignature;
m_signingInput = m_encodedHeader + "." + m_encodedPayload;
String decodedPayloadTemp = null;
String decodedHeaderTemp = null;
try {
decodedHeaderTemp = new String(Base64Util.base64urldecode(p_encodedHeader), Util.UTF8_STRING_ENCODING);
decodedPayloadTemp = new String(Base64Util.base64urldecode(p_encodedPayload), Util.UTF8_STRING_ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
m_decodedHeader = decodedHeaderTemp;
m_decodedPayload = decodedPayloadTemp;
}
示例11: OxAuthCryptoProvider
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
public OxAuthCryptoProvider(String keyStoreFile, String keyStoreSecret, String dnName) throws Exception {
if (!Util.isNullOrEmpty(keyStoreFile) && !Util.isNullOrEmpty(keyStoreSecret) /* && !Util.isNullOrEmpty(dnName) */) {
this.keyStoreFile = keyStoreFile;
this.keyStoreSecret = keyStoreSecret;
this.dnName = dnName;
keyStore = KeyStore.getInstance("JKS");
try {
File f = new File(keyStoreFile);
if (!f.exists()) {
keyStore.load(null, keyStoreSecret.toCharArray());
FileOutputStream fos = new FileOutputStream(keyStoreFile);
keyStore.store(fos, keyStoreSecret.toCharArray());
fos.close();
}
final InputStream is = new FileInputStream(keyStoreFile);
keyStore.load(is, keyStoreSecret.toCharArray());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
}
示例12: sign
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
@Override
public String sign(String signingInput, String alias, String sharedSecret, SignatureAlgorithm signatureAlgorithm) throws Exception {
if (signatureAlgorithm == SignatureAlgorithm.NONE) {
return "";
} else if (SignatureAlgorithmFamily.HMAC.equals(signatureAlgorithm.getFamily())) {
SecretKey secretKey = new SecretKeySpec(sharedSecret.getBytes(Util.UTF8_STRING_ENCODING), signatureAlgorithm.getAlgorithm());
Mac mac = Mac.getInstance(signatureAlgorithm.getAlgorithm());
mac.init(secretKey);
byte[] sig = mac.doFinal(signingInput.getBytes());
return Base64Util.base64urlencode(sig);
} else { // EC or RSA
PrivateKey privateKey = getPrivateKey(alias);
Signature signature = Signature.getInstance(signatureAlgorithm.getAlgorithm(), "BC");
//Signature signature = Signature.getInstance(signatureAlgorithm.getAlgorithm());
signature.initSign(privateKey);
signature.update(signingInput.getBytes());
return Base64Util.base64urlencode(signature.sign());
}
}
示例13: getPublicKey
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
public PublicKey getPublicKey(String alias) {
PublicKey publicKey = null;
try {
if (Util.isNullOrEmpty(alias)) {
return null;
}
java.security.cert.Certificate certificate = keyStore.getCertificate(alias);
if (certificate == null) {
return null;
}
publicKey = certificate.getPublicKey();
} catch (KeyStoreException e) {
e.printStackTrace();
}
return publicKey;
}
示例14: getEncodedCredentials
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
/**
* Returns the client credentials encoded using base64.
*
* @return The encoded client credentials.
*/
public String getEncodedCredentials() {
try {
if (hasCredentials()) {
return Base64.encodeBase64String(Util.getBytes(getCredentials()));
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
示例15: addReqParam
import org.xdi.oxauth.model.util.Util; //导入依赖的package包/类
protected void addReqParam(String p_key, String p_value) {
if (Util.allNotBlank(p_key, p_value)) {
if (request.getAuthorizationMethod() == AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER) {
clientRequest.formParameter(p_key, p_value);
} else {
clientRequest.queryParameter(p_key, p_value);
}
}
}