Package org.apache.juddi.v3.error

Examples of org.apache.juddi.v3.error.AuthTokenRequiredException


  public JUDDIApiResponse deletePublisher(String token, String publisherId) {
    HttpServletRequest request = this.getThreadLocalRequest();
    HttpSession session = request.getSession();
    JUDDIApiResponse response = new JUDDIApiResponse();
    try {
       Transport transport = WebHelper.getTransport(session.getServletContext());
            JUDDIApiPortType apiService = transport.getJUDDIApiService();
            DeletePublisher deletePublisher = new DeletePublisher();
           deletePublisher.setAuthInfo(token);
            deletePublisher.getPublisherId().add(publisherId);
            apiService.deletePublisher(deletePublisher);
           response.setSuccess(true);
View Full Code Here


    GetPublisherDetail getPublisherDetail = new GetPublisherDetail();
    getPublisherDetail.setAuthInfo(authToken);
    getPublisherDetail.getPublisherId().add(username);
   
    try {
       Transport transport = WebHelper.getTransport(session.getServletContext());
           JUDDIApiPortType apiService = transport.getJUDDIApiService();
           PublisherDetail publisherDetail = apiService.getPublisherDetail(getPublisherDetail);
              org.apache.juddi.api_v3.Publisher publisher = publisherDetail.getPublisher().get(0);
              if ("true".equalsIgnoreCase(publisher.getIsAdmin())) {
               UDDIClerkManager manager =  WebHelper.getUDDIClerkManager(session.getServletContext());
               logger.info("managerName=" + manager.getName());
View Full Code Here

 
  private AuthToken login(String username, String password, ServletContext servletContext) throws ConfigurationException, ClassNotFoundException,
    InstantiationException, IllegalAccessException, TransportException, DispositionReportFaultMessage, RemoteException,
    IllegalArgumentException, SecurityException, InvocationTargetException, NoSuchMethodException {
   
        Transport transport = WebHelper.getTransport(servletContext);
    UDDISecurityPortType securityService = transport.getUDDISecurityService();
    GetAuthToken getAuthToken = new GetAuthToken();
    getAuthToken.setUserID(username);
    getAuthToken.setCred(password);
    AuthToken authToken = securityService.getAuthToken(getAuthToken);
    log.info("User " + username + " obtained token from node=" + WebHelper.getUDDIHomeNode(servletContext).getName());
View Full Code Here

  public void logout(String username) throws ConfigurationException {
    try {
      HttpServletRequest request = getThreadLocalRequest();
      HttpSession session = request.getSession();
      String token = (String) session.getAttribute("AuthToken");
      Transport transport = WebHelper.getTransport(session.getServletContext());
      UDDISecurityPortType securityService = transport.getUDDISecurityService();
      DiscardAuthToken discardAuthToken = new DiscardAuthToken();
      discardAuthToken.setAuthInfo(token);
      securityService.discardAuthToken(discardAuthToken);
      log.info("User " + username + " invalided token");
    } catch (Exception e) {
View Full Code Here

   
    PublicationResponse response = new PublicationResponse();
    logger.debug("GetRegistrationInfo " + getRegistrationInfo + " sending get Busineses request..");
    List<Business> businesses = new ArrayList<Business>();
    try {
       Transport transport = WebHelper.getTransport(session.getServletContext());
           UDDIPublicationPortType publicationService = transport.getUDDIPublishService();
           RegisteredInfo info = publicationService.getRegisteredInfo(getRegistrationInfo);
           for (BusinessInfo businessInfo : info.getBusinessInfos().getBusinessInfo()) {
        Business business = new Business(
            businessInfo.getBusinessKey(),
            EntityForLang.getName(businessInfo.getName(),lang).getValue(),
View Full Code Here

      try {
        String clazz = getProxyTransport();
        Class<?> transportClass = Loader.loadClass(clazz);
        transport = (Transport) transportClass.getConstructor(String.class,String.class).newInstance(managerName,name);
      } catch (Exception e) {
        throw new TransportException(e.getMessage(),e);
      }
    }
    return transport;
  }
View Full Code Here

  public static final int AUTHTOKEN_RETIRED = 0;
 
  public UddiEntityPublisher getEntityPublisher(EntityManager em, String authInfo) throws DispositionReportFaultMessage {
   
    if (authInfo == null || authInfo.length() == 0)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthRequired"));
   
    org.apache.juddi.model.AuthToken modelAuthToken = em.find(org.apache.juddi.model.AuthToken.class, authInfo);
    if (modelAuthToken == null)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
   
    if (modelAuthToken.getTokenState() == AUTHTOKEN_RETIRED)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
   
    Authenticator authenticator = AuthenticatorFactory.getAuthenticator();
    UddiEntityPublisher entityPublisher = authenticator.identify(authInfo, modelAuthToken.getAuthorizedName());
   
    // Must make sure the returned publisher has all the necessary fields filled
    if (entityPublisher == null)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));

    if (entityPublisher.getAuthorizedName() == null)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));

    // Auth token is being used.  Adjust appropriate values so that it's internal 'expiration clock' is reset.
    modelAuthToken.setLastUsed(new Date());
    modelAuthToken.setNumberOfUses(modelAuthToken.getNumberOfUses() + 1);
   
View Full Code Here

      if (publisher == null)
        throw new UnknownUserException(new ErrorMessage("errors.auth.NoPublisher", authorizedName));
     
      AuthToken at = em.find(AuthToken.class, authInfo);
      if (at == null)
        throw new AuthTokenRequiredException(new ErrorMessage("E_authTokenRequired", authInfo));       
    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
      em.close();
View Full Code Here

        @Resource
        protected WebServiceContext ctx;
  public UddiEntityPublisher getEntityPublisher(EntityManager em, String authInfo) throws DispositionReportFaultMessage {
   
    if (authInfo == null || authInfo.length() == 0)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthRequired"));
   
    org.apache.juddi.model.AuthToken modelAuthToken = em.find(org.apache.juddi.model.AuthToken.class, authInfo);
    if (modelAuthToken == null)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
 
    int allowedMinutesOfInactivity = 0;
    try {
      allowedMinutesOfInactivity = AppConfig.getConfiguration().getInt(Property.JUDDI_AUTH_TOKEN_TIMEOUT, 0);
    } catch (ConfigurationException ce) {
      logger.error("Error reading property " + Property.JUDDI_AUTH_TOKEN_EXPIRATION + " from "
          + "the application's configuration. No automatic timeout token invalidation will occur. "
          + ce.getMessage(), ce);
    }
    int maxMinutesOfAge = 0;
    try {
      maxMinutesOfAge = AppConfig.getConfiguration().getInt(Property.JUDDI_AUTH_TOKEN_EXPIRATION, 0);
    } catch (ConfigurationException ce) {
      logger.error("Error reading property " + Property.JUDDI_AUTH_TOKEN_EXPIRATION + " from "
          + "the application's configuration. No automatic timeout token invalidation will occur. "
          + ce.getMessage(), ce);
    }
    Date now = new Date();
    // 0 or negative means token does not expire
    if (allowedMinutesOfInactivity > 0) {
      // expire tokens after # minutes of inactivity
      // compare the time in milli-seconds
      if (now.getTime() > modelAuthToken.getLastUsed().getTime() + allowedMinutesOfInactivity * 60000l) {
        logger.info("AUDIT: FAILTURE Token " + modelAuthToken.getAuthToken() + " expired due to inactivity "+getRequestorsIPAddress());
        modelAuthToken.setTokenState(AUTHTOKEN_RETIRED);
      }
    }
    if (maxMinutesOfAge > 0) {
      // expire tokens when max age is reached
      // compare the time in milli-seconds
      if (now.getTime() > modelAuthToken.getCreated().getTime()  + maxMinutesOfAge * 60000l) {
                           
        logger.info("AUDIT: FAILURE - Token " + modelAuthToken.getAuthorizedName() + " expired due to old age " + getRequestorsIPAddress());
        modelAuthToken.setTokenState(AUTHTOKEN_RETIRED);
      }
    }

    if (modelAuthToken.getTokenState() == AUTHTOKEN_RETIRED){
                   
      throw new AuthTokenExpiredException(new ErrorMessage("errors.auth.AuthTokenExpired"));
                }
    if (ctx !=null){
                    try{
                        boolean check=true;
                        try{
                            check=AppConfig.getConfiguration().getBoolean(Property.JUDDI_AUTH_TOKEN_ENFORCE_SAME_IP, true);
                        }
                        catch (ConfigurationException ex){
                            logger.warn("Error loading config property " + Property.JUDDI_AUTH_TOKEN_ENFORCE_SAME_IP +
                                    " Enforcing Same IP for Auth Tokens will be enabled by default", ex);
                        }
                        if (check){
                            MessageContext mc = ctx.getMessageContext();
                            HttpServletRequest req = null;
                            if (mc!=null){
                                req=(HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST);
                            }
                            if (req!=null &&
                                    modelAuthToken.getIPAddress()!=null &&
                                    modelAuthToken.getIPAddress()!=null &&
                                    !modelAuthToken.getIPAddress().equalsIgnoreCase(req.getRemoteAddr()))
                            {
                                modelAuthToken.setTokenState(AUTHTOKEN_RETIRED);
                                logger.error("AUDIT FAILURE - Security Alert - Attempt to use issued auth token from a different IP address, user " +
                                        modelAuthToken.getAuthorizedName() + ", issued IP " + modelAuthToken.getIPAddress() +
                                        ", attempted use from " + req.getRemoteAddr() + ", forcing reauthentication.");
                                throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
                                //invalidate the token, someone's intercepted it or it was reused on another ip
                            }
                        }
                    }
                    catch (Exception ex){
                        if (ex instanceof AuthTokenRequiredException)
                            throw (AuthTokenRequiredException)ex;
                        logger.error("unexpected error caught looking up requestor's ip address", ex);
                    }
                   
                }
    Authenticator authenticator = AuthenticatorFactory.getAuthenticator();
    UddiEntityPublisher entityPublisher = authenticator.identify(authInfo, modelAuthToken.getAuthorizedName());
   
    // Must make sure the returned publisher has all the necessary fields filled
    if (entityPublisher == null) {
                    logger.warn("AUDIT FAILURE - Auth token invalided, publisher does not exist "+ getRequestorsIPAddress());
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
                }
    if (entityPublisher.getAuthorizedName() == null){
                    logger.warn("AUDIT FAILURE - Auth token invalided, username does exist"+ getRequestorsIPAddress());
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
                }
    // Auth token is being used.  Adjust appropriate values so that it's internal 'expiration clock' is reset.
    modelAuthToken.setLastUsed(new Date());
    modelAuthToken.setNumberOfUses(modelAuthToken.getNumberOfUses() + 1);
   
View Full Code Here

  Log logger = LogFactory.getLog(this.getClass());
 
  public UddiEntityPublisher getEntityPublisher(EntityManager em, String authInfo) throws DispositionReportFaultMessage {
   
    if (authInfo == null || authInfo.length() == 0)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthRequired"));
   
    org.apache.juddi.model.AuthToken modelAuthToken = em.find(org.apache.juddi.model.AuthToken.class, authInfo);
    if (modelAuthToken == null)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
 
    int allowedMinutesOfInactivity = 0;
    try {
      allowedMinutesOfInactivity = AppConfig.getConfiguration().getInt(Property.JUDDI_AUTH_TOKEN_TIMEOUT, 0);
    } catch (ConfigurationException ce) {
      logger.error("Error reading property " + Property.JUDDI_AUTH_TOKEN_EXPIRATION + " from "
          + "the application's configuration. No automatic timeout token invalidation will occur. "
          + ce.getMessage(), ce);
    }
    int maxMinutesOfAge = 0;
    try {
      maxMinutesOfAge = AppConfig.getConfiguration().getInt(Property.JUDDI_AUTH_TOKEN_EXPIRATION, 0);
    } catch (ConfigurationException ce) {
      logger.error("Error reading property " + Property.JUDDI_AUTH_TOKEN_EXPIRATION + " from "
          + "the application's configuration. No automatic timeout token invalidation will occur. "
          + ce.getMessage(), ce);
    }
    Date now = new Date();
    // 0 or negative means token does not expire
    if (allowedMinutesOfInactivity > 0) {
      // expire tokens after # minutes of inactivity
      // compare the time in milli-seconds
      if (now.getTime() > modelAuthToken.getLastUsed().getTime() + allowedMinutesOfInactivity * 60000l) {
        logger.debug("Token " + modelAuthToken.getAuthToken() + " expired due to inactivity");
        modelAuthToken.setTokenState(AUTHTOKEN_RETIRED);
      }
    }
    if (maxMinutesOfAge > 0) {
      // expire tokens when max age is reached
      // compare the time in milli-seconds
      if (now.getTime() > modelAuthToken.getCreated().getTime()  + maxMinutesOfAge * 60000l) {
        logger.debug("Token " + modelAuthToken.getAuthToken() + " expired due to old age");
        modelAuthToken.setTokenState(AUTHTOKEN_RETIRED);
      }
    }

    if (modelAuthToken.getTokenState() == AUTHTOKEN_RETIRED)
      throw new AuthTokenExpiredException(new ErrorMessage("errors.auth.AuthTokenExpired"));
   
    Authenticator authenticator = AuthenticatorFactory.getAuthenticator();
    UddiEntityPublisher entityPublisher = authenticator.identify(authInfo, modelAuthToken.getAuthorizedName());
   
    // Must make sure the returned publisher has all the necessary fields filled
    if (entityPublisher == null)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));

    if (entityPublisher.getAuthorizedName() == null)
      throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));

    // Auth token is being used.  Adjust appropriate values so that it's internal 'expiration clock' is reset.
    modelAuthToken.setLastUsed(new Date());
    modelAuthToken.setNumberOfUses(modelAuthToken.getNumberOfUses() + 1);
   
View Full Code Here

TOP

Related Classes of org.apache.juddi.v3.error.AuthTokenRequiredException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.